
#!/usr/bin/python3
# -*- coding: utf-8 -*-
'''
# @file   : pwd_strength.py
# @author : weichy
# @date   : 2019/01/03
# @version: 4.0
# @desc   :  测试密码的强度
            2.0循环的终止,限制密码的尝试次数
            3.0文件的操作
            4.0读取写入的密码文件
'''
def check_number_exist(password_str):
    #判断字符串中是否含有数字
    has_number = False
    for c in password_str:
        if c.isnumeric():
            has_number = True
            break
    return has_number
def check_letter_exist(password_str):
    #判断字符串中是否含有数字
    has_letter = False
    for c in password_str:
        if c.isalpha():
            has_letter = True

    return has_letter

def main():

    # try_times =5
    # while try_times>0:


    #     password = input('请输入密码：')


    #     # 密码强度
    #     strength_level = 0

    #     # 规则1： 密码长度大于8
    #     if len(password)>8:
    #         strength_level +=1
    #     else:
    #         print('密码长度要求至少8位。')
    #     # 规则2： 密码要包含数字
    #     if check_number_exist(password):
    #         strength_level +=1
    #     else: 
    #         print('密码中不包含数字。')
    #     # 规则3:密码要包含字母
    #     if check_letter_exist(password):
    #         strength_level +=1
    #     else: 
    #         print('密码中不包含字母。')
    #     with open('password_3.0.txt', 'a') as f:   
    #         # print(f.read()) 
    #         f.write('密码：{}，强度：{}\n'.format(password,strength_level))
    #         f.close()           

    #     if strength_level >=3:
    #         print('恭喜！密码强度合格。')


    #         break
    #     else:
    #         print('密码强度不合格。')
    #         try_times -=1
    #     print()

    # if try_times <=0:
    #     print('尝试次数过多，密码设置失败。')
    # 读取文件
    with  open('password_3.0.txt','r') as f:
        # content = f.read()
        # print(content)
        # 2.readline()
        # line=f.readline()
        # print(line)
        # line=f.readline()
        # print(line)
        # 3.readline()

        for line in f.readlines():
            print('read:{}'.format(line)



if __name__ == '__main__':
    main()